package com.jsoft.util;

import java.util.List;

/**
 * @author zhangxuehan
 * @email 2302630156@qq.com
 * @date 2023/2/20
 */
public class PageHelper<T> {
    /**
     * 当前页
     */
    private int currentPage ;
    /**
     * 最后一页
     */
    private int lastPage;
    /**
     * 总记录数
     */
    private long total;
    /**
     * 每页显示的条数
     */
    private int pageSize = 5;
    /**
     * 起始位置
     */
    private int start;
    /**
     * 显示的数据
     */
    private List<T> data;

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getLastPage() {
        return lastPage;
    }

    public void setLastPage(int lastPage) {
        this.lastPage = lastPage;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
        /**
         * 总页数
         */
        this.lastPage = (int)Math.ceil((double)total / pageSize);
//        System.out.println("lastPage------------------------------------"+lastPage);
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getStart() {
        return (currentPage - 1) * pageSize;
    }

    public void setStart(int start) {
        this.start = start;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }
}
